<html>
<head><meta charset="utf-8"><title>Why do we need `StructuralEq` in addition to `Eq` · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html">Why do we need `StructuralEq` in addition to `Eq`</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="193075247"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193075247" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193075247">(Apr 06 2020 at 17:35)</a>:</h4>
<p><span class="user-mention" data-user-id="116083">@pnkfelix</span> there's multiple topics being discussed in the other thread, so I thought I'd ask in a separate one: why do we need a separate <code>StructuralEq</code>?</p>



<a name="193075353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193075353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193075353">(Apr 06 2020 at 17:36)</a>:</h4>
<p>its in the docs, isn't it?</p>



<a name="193075379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193075379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193075379">(Apr 06 2020 at 17:36)</a>:</h4>
<p>the issue is that there was a case where the constant in question does not implement <code>Eq</code></p>



<a name="193075402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193075402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193075402">(Apr 06 2020 at 17:36)</a>:</h4>
<p>The docs say:</p>
<blockquote>
<p>(The problem in the above code is that Wrap&lt;fn(&amp;())&gt; does not implement PartialEq, nor Eq, because for&lt;'a&gt; fn(&amp;'a _) does not implement those traits.)</p>
</blockquote>



<a name="193075410"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193075410" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193075410">(Apr 06 2020 at 17:36)</a>:</h4>
<p><a href="https://doc.rust-lang.org/nightly/std/marker/trait.StructuralEq.html" title="https://doc.rust-lang.org/nightly/std/marker/trait.StructuralEq.html">https://doc.rust-lang.org/nightly/std/marker/trait.StructuralEq.html</a></p>



<a name="193075424"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193075424" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193075424">(Apr 06 2020 at 17:37)</a>:</h4>
<p>but we needed to still encode the fact that it <em>did</em> derive <code>Eq</code></p>



<a name="193075451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193075451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193075451">(Apr 06 2020 at 17:37)</a>:</h4>
<p>i.e., the derived <code>Eq</code> has bounds that are not satisfied</p>



<a name="193075462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193075462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193075462">(Apr 06 2020 at 17:37)</a>:</h4>
<p><span class="user-mention" data-user-id="118594">@ecstatic-morse</span> the docs sound confused</p>



<a name="193075467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193075467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193075467">(Apr 06 2020 at 17:37)</a>:</h4>
<p>but we still need to mark it as usuable in a pattern</p>



<a name="193075490"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193075490" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193075490">(Apr 06 2020 at 17:37)</a>:</h4>
<p>Do function pointers not implement <code>PartialEq</code>?</p>



<a name="193075509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193075509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193075509">(Apr 06 2020 at 17:37)</a>:</h4>
<p>I've already answered this: <code>#[derive(PartialEq, Eq)]</code> needs to be detected but the derives <em>can't know about eachother</em></p>



<a name="193075510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193075510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193075510">(Apr 06 2020 at 17:37)</a>:</h4>
<p>function pointers that have lifetimes do not</p>



<a name="193075573"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193075573" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193075573">(Apr 06 2020 at 17:38)</a>:</h4>
<p>so <em>the only thing they can do</em> is each implement a different trait</p>



<a name="193075583"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193075583" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193075583">(Apr 06 2020 at 17:38)</a>:</h4>
<p>that is tested later</p>



<a name="193075588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193075588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193075588">(Apr 06 2020 at 17:38)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> in an ideal world we would just have <code>StrucutralPartialEq</code> and not <em>need</em> the derive of <code>Eq</code></p>



<a name="193075595"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193075595" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193075595">(Apr 06 2020 at 17:38)</a>:</h4>
<p>because <code>Eq</code> has no methods</p>



<a name="193075611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193075611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193075611">(Apr 06 2020 at 17:38)</a>:</h4>
<p>so we in theory should be able to just test that <code>Eq</code> is <em>implemented</em></p>



<a name="193075622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193075622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193075622">(Apr 06 2020 at 17:38)</a>:</h4>
<p>but it could have the wrong bounds</p>



<a name="193075630"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193075630" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193075630">(Apr 06 2020 at 17:38)</a>:</h4>
<p>hence why I think the docs are confused</p>



<a name="193075656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193075656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193075656">(Apr 06 2020 at 17:39)</a>:</h4>
<p>the <code>Eq</code> impl <em>must fundamentally</em> be a <code>#[derive(Eq)]</code> impl</p>



<a name="193075662"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193075662" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193075662">(Apr 06 2020 at 17:39)</a>:</h4>
<p>well I suppose it depends on what the goals are</p>



<a name="193075675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193075675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193075675">(Apr 06 2020 at 17:39)</a>:</h4>
<p>those are special in that they test the fields</p>



<a name="193075694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193075694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193075694">(Apr 06 2020 at 17:39)</a>:</h4>
<p>the generated impl <em>is not</em> <code>impl Eq for Foo {}</code></p>



<a name="193075713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193075713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193075713">(Apr 06 2020 at 17:39)</a>:</h4>
<p>maybe this is the point of confusion?</p>



<a name="193075724"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193075724" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193075724">(Apr 06 2020 at 17:39)</a>:</h4>
<p>I don't know.</p>



<a name="193075733"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193075733" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193075733">(Apr 06 2020 at 17:39)</a>:</h4>
<p>"it has no methods" is irrelevant and I think actually false</p>



<a name="193075821"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193075821" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193075821">(Apr 06 2020 at 17:40)</a>:</h4>
<p>/me is not sure where the code to assert <code>Eq</code> on fields is generated. a method would make sense</p>



<a name="193075903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193075903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193075903">(Apr 06 2020 at 17:40)</a>:</h4>
<p>Let me try a different tack on this question</p>



<a name="193076006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193076006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193076006">(Apr 06 2020 at 17:40)</a>:</h4>
<p>yeah <code>Eq</code> has a method <a href="https://github.com/rust-lang/rust/blob/master/src/libcore/cmp.rs#L271-L281" title="https://github.com/rust-lang/rust/blob/master/src/libcore/cmp.rs#L271-L281">https://github.com/rust-lang/rust/blob/master/src/libcore/cmp.rs#L271-L281</a></p>



<a name="193076014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193076014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193076014">(Apr 06 2020 at 17:40)</a>:</h4>
<p>The hypothetical check is one where we just look for an impl of <code>StructuralPartialEq</code> and an impl of <code>Eq</code></p>



<a name="193076099"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193076099" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193076099">(Apr 06 2020 at 17:41)</a>:</h4>
<p>what is the scenario, <span class="user-mention" data-user-id="119009">@eddyb</span> , where you are envisaging that causing breakage for the structural-equality analysis?</p>



<a name="193076163"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193076163" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193076163">(Apr 06 2020 at 17:41)</a>:</h4>
<p>you mean because the fields are recursively checked?</p>



<a name="193076173"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193076173" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193076173">(Apr 06 2020 at 17:41)</a>:</h4>
<p>apart from the one documented in the docs, which is due to the (I think we all agree) compiler bug that <code>for &lt;'a&gt; fn (&amp;'a _)</code> does not impl <code>Eq</code></p>



<a name="193076290"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193076290" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193076290">(Apr 06 2020 at 17:42)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> right. What's the problem with relying on the <code>Eq</code> impl alone? So what if it adds that extra condition?</p>



<a name="193076327"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193076327" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193076327">(Apr 06 2020 at 17:43)</a>:</h4>
<p>I think requiring <code>#[derive(PartialEq, Eq)]</code> should remain the <em>only</em> opt-in and changing that is a completely different discussion from why both traits are needed <em>right now</em></p>



<a name="193076380"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193076380" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193076380">(Apr 06 2020 at 17:43)</a>:</h4>
<p>I don't <em>mind</em> that outcome</p>



<a name="193076402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193076402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193076402">(Apr 06 2020 at 17:43)</a>:</h4>
<p>but I'm still confused as to why you are so militant about it</p>



<a name="193076485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193076485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193076485">(Apr 06 2020 at 17:44)</a>:</h4>
<p>that is, the example in the docs seems to ignore the fact that we were using <code>#[structural_match]</code> gated on <em>both</em> traits being auto-derived <em>before</em> we ever had to switch to these extra traits</p>



<a name="193076560"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193076560" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193076560">(Apr 06 2020 at 17:44)</a>:</h4>
<p>My memory is that the <code>#[structural_match]</code> wasn't gated on the traits. It was gated on the derives.</p>



<a name="193076565"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193076565" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193076565">(Apr 06 2020 at 17:44)</a>:</h4>
<p>or sorry</p>



<a name="193076570"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193076570" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193076570">(Apr 06 2020 at 17:44)</a>:</h4>
<p>that's what you said</p>



<a name="193076574"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193076574" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193076574">(Apr 06 2020 at 17:45)</a>:</h4>
<p>sorry yes I mean on the traits in the derive list</p>



<a name="193076603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193076603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193076603">(Apr 06 2020 at 17:45)</a>:</h4>
<p>so yes, if the goal is to preserve the exact semantcs that we had before</p>



<a name="193076607"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193076607" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193076607">(Apr 06 2020 at 17:45)</a>:</h4>
<p>it just feels like there's a lot of confusion here</p>



<a name="193076608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193076608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193076608">(Apr 06 2020 at 17:45)</a>:</h4>
<p>then sure, you'd need to have two traits</p>



<a name="193076620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193076620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193076620">(Apr 06 2020 at 17:45)</a>:</h4>
<p>and a lot of factors that don't help</p>



<a name="193076623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193076623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193076623">(Apr 06 2020 at 17:45)</a>:</h4>
<p>but that wasn't even the original goal when I first started working on switching to a trait</p>



<a name="193076648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193076648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193076648">(Apr 06 2020 at 17:45)</a>:</h4>
<p>mechanically, <code>Structural{Partial,}Eq</code> are <em>attributes</em></p>



<a name="193076708"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193076708" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193076708">(Apr 06 2020 at 17:46)</a>:</h4>
<p>and IMO that's what the docs should describe</p>



<a name="193076714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193076714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193076714">(Apr 06 2020 at 17:46)</a>:</h4>
<p>and the names are wrong</p>



<a name="193076739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193076739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193076739">(Apr 06 2020 at 17:46)</a>:</h4>
<p>apart from the case where we manually implement them (for <code>PhantomData</code>)</p>



<a name="193076769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193076769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193076769">(Apr 06 2020 at 17:46)</a>:</h4>
<p>which arguably is just another instance of an attribute encoded as a trait</p>



<a name="193076774"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193076774" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193076774">(Apr 06 2020 at 17:46)</a>:</h4>
<p>that's just <code>#[derive(PartialEq, Eq)]</code> for <code>PhantomData</code> but w/o the bounds</p>



<a name="193076785"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193076785" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193076785">(Apr 06 2020 at 17:46)</a>:</h4>
<p>(because there are no fields)</p>



<a name="193076810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193076810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193076810">(Apr 06 2020 at 17:47)</a>:</h4>
<p>and because it would break things to have the bounds, yes</p>



<a name="193076817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193076817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193076817">(Apr 06 2020 at 17:47)</a>:</h4>
<p>it's only necessary because the derive-generated bounds don't match the fields</p>



<a name="193076898"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193076898" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193076898">(Apr 06 2020 at 17:48)</a>:</h4>
<p>as in, they use the generic parameters, not the fields, right? You're just talking about how <code>derive</code> works in that remark?</p>



<a name="193077021"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193077021" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193077021">(Apr 06 2020 at 17:48)</a>:</h4>
<p>yeah</p>



<a name="193077035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193077035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193077035">(Apr 06 2020 at 17:48)</a>:</h4>
<p>So okay</p>



<a name="193077057"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193077057" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193077057">(Apr 06 2020 at 17:49)</a>:</h4>
<p>I 100% agree that the traits here effectively are attributes</p>



<a name="193077107"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193077107" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193077107">(Apr 06 2020 at 17:49)</a>:</h4>
<p>and that they are encoded as traits for ... reasons ...</p>



<a name="193077134"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193077134" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193077134">(Apr 06 2020 at 17:49)</a>:</h4>
<p>this explains, for example, why <span class="user-mention" data-user-id="124288">@oli</span> was confused about libcore not having impls of these traits</p>



<a name="193077146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193077146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193077146">(Apr 06 2020 at 17:49)</a>:</h4>
<p>for primitives</p>



<a name="193077181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193077181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193077181">(Apr 06 2020 at 17:50)</a>:</h4>
<p>and that's because they only make sense where <code>#[structural_match]</code> did</p>



<a name="193077233"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193077233" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193077233">(Apr 06 2020 at 17:50)</a>:</h4>
<p>but I still don't understand why you are insisting it would be <em>wrong</em> to check for <code>StructuralPartialEq</code> and <code>Eq</code> directly instead of <code>StructuralEq</code></p>



<a name="193077248"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193077248" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193077248">(Apr 06 2020 at 17:50)</a>:</h4>
<p>there's no extra semantics involved</p>



<a name="193077287"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193077287" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193077287">(Apr 06 2020 at 17:50)</a>:</h4>
<p>it would be a change in the semantics for structural-match, yes</p>



<a name="193077309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193077309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193077309">(Apr 06 2020 at 17:50)</a>:</h4>
<p>but I don't yet see where it causes things to go wrong</p>



<a name="193077414"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193077414" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193077414">(Apr 06 2020 at 17:51)</a>:</h4>
<p>I'm sorry if you feel like we are talking in circles, but I'm just not getting it</p>



<a name="193077431"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193077431" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193077431">(Apr 06 2020 at 17:51)</a>:</h4>
<p>if we've value-based and allow things like <code>None::&lt;T&gt;</code> always being structurally matchable no matter, then we can't be checking <code>Option&lt;T&gt;: Eq</code>, since that might be false, whereas <code>Option&lt;T&gt;: AutoDerivedEq</code> would fit</p>



<a name="193077450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193077450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193077450">(Apr 06 2020 at 17:51)</a>:</h4>
<p>unless you're talking about <em>looking for an <code>impl</code></em> outside of the trait system?</p>



<a name="193077496"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193077496" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193077496">(Apr 06 2020 at 17:52)</a>:</h4>
<p>without the bounds being met</p>



<a name="193077599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193077599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193077599">(Apr 06 2020 at 17:52)</a>:</h4>
<p>frankly it would make more sense to me to just use <code>AutoDerivedPartialEq</code> and that's it. no <code>Eq</code> check (assuming all fields are recursively checked by the analysis)</p>



<a name="193077624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193077624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193077624">(Apr 06 2020 at 17:53)</a>:</h4>
<p>if you check for <code>Eq</code> it should be consistent with <code>PartialEq</code></p>



<a name="193077629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193077629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193077629">(Apr 06 2020 at 17:53)</a>:</h4>
<p>Ah, okay, so now you're looping in the ... "value-based" system (historically I've thought of it as expression-based, but I suppose this depends on whether one implements it as a traversal of the AST, or as a compile-time evaluation of a const-expression)</p>



<a name="193077682"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193077682" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193077682">(Apr 06 2020 at 17:53)</a>:</h4>
<p>and yes, <em>that</em> may well be an area where we are better off sticking with the system as written. I wasn't thinking about that.</p>



<a name="193077688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193077688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193077688">(Apr 06 2020 at 17:53)</a>:</h4>
<p>I mean "value" in the broad sense of "a value being constructed" (by a HIR expression or a series of MIR statements)</p>



<a name="193077784"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193077784" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193077784">(Apr 06 2020 at 17:54)</a>:</h4>
<p>"dataflow" might be more appropriate I suppose</p>



<a name="193077889"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193077889" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193077889">(Apr 06 2020 at 17:55)</a>:</h4>
<p>okay thank you for the clarification, both of the local terminology and of your thinking more broadly.</p>



<a name="193077953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193077953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193077953">(Apr 06 2020 at 17:55)</a>:</h4>
<p>my priority was untangling the confusion that the traits have apparently created</p>



<a name="193077982"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193077982" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193077982">(Apr 06 2020 at 17:56)</a>:</h4>
<p>because we weren't understanding eachother (I mean the 4 of us) very well at first</p>



<a name="193078497"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193078497" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193078497">(Apr 06 2020 at 17:59)</a>:</h4>
<p>I didn't realize there was a shortcoming around function pointers with lifetimes, but the second half of the conversation was also helpful.</p>



<a name="193078774"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193078774" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193078774">(Apr 06 2020 at 18:01)</a>:</h4>
<p>I think the <code>fn</code> pointer thing is a bit of a red herring, the clear breakdown for me is in something like <code>None::&lt;String&gt;</code> (which I think we allow today?)</p>



<a name="193078812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193078812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193078812">(Apr 06 2020 at 18:01)</a>:</h4>
<p>yeah, I probably should have called out that aspect of the example in the docs</p>



<a name="193078909"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193078909" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193078909">(Apr 06 2020 at 18:02)</a>:</h4>
<p>We allow some cases like <span class="user-mention" data-user-id="119009">@eddyb</span> describes, but the indirect_structural_match lint (which is allow by default) will trigger on some that we would prefer not to...</p>



<a name="193078987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193078987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193078987">(Apr 06 2020 at 18:03)</a>:</h4>
<p>namely <a href="https://github.com/rust-lang/rust/issues/62614" title="https://github.com/rust-lang/rust/issues/62614">#62614</a> is an example I can cite</p>



<a name="193079156"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193079156" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193079156">(Apr 06 2020 at 18:04)</a>:</h4>
<p>oh and of course <a href="https://github.com/rust-lang/rust/issues/65466" title="https://github.com/rust-lang/rust/issues/65466">#65466</a> is the really bad one ....</p>



<a name="193161800"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193161800" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193161800">(Apr 07 2020 at 09:42)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116083">pnkfelix</span> <a href="#narrow/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60/near/193078909" title="#narrow/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60/near/193078909">said</a>:</p>
<blockquote>
<p>We allow some cases like <span class="user-mention silent" data-user-id="119009">eddyb</span> describes, but the indirect_structural_match lint (which is allow by default) will trigger on some that we would prefer not to...</p>
</blockquote>
<p>The RFC states otherwise btw; It seems like "we would prefer not to" was not a decision that was made as a team</p>



<a name="193161850"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193161850" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193161850">(Apr 07 2020 at 09:42)</a>:</h4>
<p>That is, the RFC encodes a fully type-based set of rules</p>



<a name="193167886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193167886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193167886">(Apr 07 2020 at 10:44)</a>:</h4>
<p>I recommended replacing <code>#[structural_match]</code> with traits under assumption that no dataflow analysis happens and all the analysis is based on the <code>StructuralPartialEq</code> traits, which are regular traits and not attributes in any way.</p>



<a name="193167939"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193167939" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193167939">(Apr 07 2020 at 10:45)</a>:</h4>
<p>I was calling them "attributes" because their bounds don't matter AFAIK</p>



<a name="193167957"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193167957" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193167957">(Apr 07 2020 at 10:45)</a>:</h4>
<p>or at least I think they use no bounds?</p>



<a name="193167960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193167960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193167960">(Apr 07 2020 at 10:45)</a>:</h4>
<p>(And types of all fields in the constant must satisfy the <code>StructuralPartialEq</code> bound recursively.)</p>



<a name="193167978"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193167978" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193167978">(Apr 07 2020 at 10:45)</a>:</h4>
<p>(For the constant to be usable in patterns.)</p>



<a name="193167986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193167986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193167986">(Apr 07 2020 at 10:45)</a>:</h4>
<p>so they work effectively as an attribute on the <code>struct</code>/<code>enum</code></p>



<a name="193178736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193178736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193178736">(Apr 07 2020 at 12:27)</a>:</h4>
<p>how about an attribute on the <code>impl StructuralPartialEq for TheType</code>?</p>



<a name="193178953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193178953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193178953">(Apr 07 2020 at 12:29)</a>:</h4>
<p>do you mean on the <code>PartialEq</code> impl?</p>



<a name="193178971"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193178971" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193178971">(Apr 07 2020 at 12:29)</a>:</h4>
<p>there might already be an "automatically derived" attribute</p>



<a name="193179002"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193179002" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193179002">(Apr 07 2020 at 12:30)</a>:</h4>
<p>right... so we can just use that?</p>



<a name="193179036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193179036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193179036">(Apr 07 2020 at 12:30)</a>:</h4>
<p>the problem is that you'd have to manually search for the <code>impl</code></p>



<a name="193179068"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193179068" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193179068">(Apr 07 2020 at 12:30)</a>:</h4>
<p>but that's not that bad</p>



<a name="193179108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193179108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193179108">(Apr 07 2020 at 12:30)</a>:</h4>
<p>you can rely on the <code>fast_reject</code> mechanism</p>



<a name="193179119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193179119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193179119">(Apr 07 2020 at 12:30)</a>:</h4>
<p>we could make <code>automatically_derived</code> a field on the ast/hir structures for impls</p>



<a name="193179139"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193179139" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193179139">(Apr 07 2020 at 12:30)</a>:</h4>
<p>that's not the interesting bit</p>



<a name="193179203"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193179203" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193179203">(Apr 07 2020 at 12:31)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> <code>Span</code> also has the derive info and I don't think you can forge that :P</p>



<a name="193179230"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193179230" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193179230">(Apr 07 2020 at 12:31)</a>:</h4>
<p>although I wonder if you could make your own derives with the same names that create the same impls</p>



<a name="193179275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193179275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193179275">(Apr 07 2020 at 12:32)</a>:</h4>
<p>anyway the tricky bit is finding the impls</p>



<a name="193179298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193179298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193179298">(Apr 07 2020 at 12:32)</a>:</h4>
<p>because you can't use the trait system like you can with the Structural traits</p>



<a name="193179327"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193179327" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193179327">(Apr 07 2020 at 12:32)</a>:</h4>
<p>ah</p>



<a name="193179334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193179334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193179334">(Apr 07 2020 at 12:32)</a>:</h4>
<p>right</p>



<a name="193188032"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193188032" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193188032">(Apr 07 2020 at 13:35)</a>:</h4>
<p><span class="user-mention silent" data-user-id="126931">centril</span> <a href="#narrow/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60/near/193161800" title="#narrow/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60/near/193161800">said</a>:</p>
<blockquote>
<p>The RFC states otherwise btw; It seems like "we would prefer not to" was not a decision that was made as a team</p>
</blockquote>
<p>The lang team <em>has</em> discussed the matter, at least tangentially. See for example the meeting from <a href="https://github.com/rust-lang/lang-team/blob/master/minutes/2020-01-02.md#nominated-prs" title="https://github.com/rust-lang/lang-team/blob/master/minutes/2020-01-02.md#nominated-prs">January of this year</a>, where we discussed PR <a href="https://github.com/rust-lang/rust/issues/67088" title="https://github.com/rust-lang/rust/issues/67088">#67088</a>.</p>



<a name="193188175"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Why%20do%20we%20need%20%60StructuralEq%60%20in%20addition%20to%20%60Eq%60/near/193188175" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Why.20do.20we.20need.20.60StructuralEq.60.20in.20addition.20to.20.60Eq.60.html#193188175">(Apr 07 2020 at 13:36)</a>:</h4>
<p>The type-based check is simply too conservative to be deployed in practice.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>